package wangjg.android.common.ui;

import android.content.Context;
import android.graphics.PixelFormat;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;

/**
 * 悬浮窗
 * @author wangjg
 *
 */
public class FloatWindow {
	private Context context;

	public FloatWindow(Context context){
		this.context = context;
	}
	
	public void show(View view){
		LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,  
                LayoutParams.WRAP_CONTENT, LayoutParams.TYPE_SYSTEM_ERROR,  
                LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT);
		layoutParams.gravity = Gravity.LEFT | Gravity.TOP;  
		
		WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
		wm.addView(view, layoutParams);
	}
	
}
